#include<vector>
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>
using namespace std;
stack<int> s;
bool IsPopOrder(vector<int>& pushV, vector<int>& popV) {
    int push_i;
    int pop_i = 0;
    for (push_i = 0; push_i < pushV.size(); push_i++) {
        s.push(pushV[push_i]);
        while (!s.empty() && s.top() == popV[pop_i]) {
            s.pop();
            pop_i++;
        }
    }
    return s.empty();

}
int main() 
{
    vector<int> nums1 = { 1,2,3,4,5 };
    vector<int> nums2 = { 4,5,3,2,1 };
    cout<<IsPopOrder(nums1, nums2);
    return 0;
}